package com.systop.controller;

import com.systop.pojo.Admin;
import com.systop.service.AdminSevice;
import com.systop.unti.Md5Utils;
import com.systop.unti.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

@RestController
public class AdminController {
    @Autowired
    private AdminSevice adminSevice;
    //登陆方法
    @RequestMapping(value = "/admin_login",method = RequestMethod.POST)
    public ResponseResult adminlogin(@RequestParam("admin_name") String admin_name,@RequestParam("admin_password") String admin_password,HttpSession session){
        System.out.println("+++++++++++++++++++++登陆++++++++++++++++++");
        admin_password=Md5Utils.MD5(admin_password);
        session.setAttribute("username",admin_name);
        session.setAttribute("password",admin_password);
        System.out.println("+++++++++++++++++++++登陆++++++++++++++++++");
        System.out.println(admin_name);
        System.out.println(admin_password);
        return adminSevice.login(admin_name,admin_password);
    }
    //注册方法
    @RequestMapping(value = "/admin_loginin",method = RequestMethod. POST)
    public ResponseResult adminloginin(@RequestParam("admin_name") String admin_name,@RequestParam("admin_password") String admin_password){
        admin_password=Md5Utils.MD5(admin_password);
        System.out.println("+++++++++++++++++++++注册++++++++++++++++++");
        System.out.println(admin_name);
        System.out.println(admin_password);
        return adminSevice.loginin(admin_name,admin_password);

    }
}
